function init_comment_rating_span(a, c, m) {
    var h = m.split(",");
    if (h) for (var j = 0; j < h.length; j++) {
        var e = a + "_commentrating_" + c + "_" + h[j], f = getCookie(e);
        if (f) {
            var k = $(".commentList").find("#cdc_support_" + h[j] + ":first").find("a").text(), n = k.substr(2, k.length - 3);
            if (n != "0") var b = "current"; else var b = "";
            var l = $(".commentList").find("#cdc_oppose_" + h[j] + ":first").find("a").text(), g = l.substr(2, l.length - 3);
            if (g != "0") var d = "current"; else var d = "";
            f.toUpperCase() == "SUPPORT" && ($(".commentList").find("#cdc_support_" + h[j]).html('<a class="' + b + '">' + k + "</a>"), $(".commentList").find("#cdc_oppose_" + h[j]).html('<a class="' + d + '">' + l + "</a>")), f.toUpperCase() == "OPPOSE" && ($(".commentList").find("#cdc_support_" + h[j]).html('<a class="' + b + '">' + k + "</a>"), $(".commentList").find("#cdc_oppose_" + h[j]).html('<a class="' + d + '">' + l + "</a>"));
        }
    }
}

function comment_rating_ajax(id,type,num) {
	var url = null;
	var obj = null;
	var result = null;
	if(type=='ding'){
		url = '/updateding.html';
		obj="ding_"+id;
		result = "顶("+(parseInt(num)+1)+")";
	}else if(type=='cai'){
		url = '/updatecai.html';
		obj = "cai_"+id;
		result = "踩("+(parseInt(num)+1)+")";
	}
    $.ajax({
        "type": "POST",
        "url": url,
        "dataType": "json",
        "data": {
            "id": id
        },
        "success": function(f) {
            if(f.result=='ok'){
            	$("#"+obj).text(result);
            }
        }
    });
}

function showComments(j, f) {
    var g = document.getElementById("li-comment-" + f), h = g.getElementsByTagName("blockquote");
    if (h.length > 0) {
        var c = h.length;
        if (c > j) {
            for (var e = j + 1; e <= c; e++) {
                var a = document.getElementById("comment_" + f + "_depth_" + e);
                a && (a.style.display = "block");
            }
            var d = document.getElementById("show_comment_more_div_" + f);
            d && d.parentNode.removeChild(d), $(".commentBlockquote").find(".commentBlockquote").removeClass("whiteBgHover"), $(".commentBlockquote").find(".commentBlockquote_div").removeClass("commentBlockquoteHover");
        }
    }
}

function commentBlockquote(b, a) {
    jQuery(".commentBlockquote").mouseover(function(c) {
        var e = $(this).find(".supportBox:first").attr("id"), i = e.split("_"), l = i[3], n = i[0], g = getCookie(b + "_commentrating_" + a + "_" + l), h = $("#li-comment-" + n).find("#cdc_support_" + l + ":first").html();
        if (h) {
            var k = h.lastIndexOf("("), d = h.lastIndexOf(")");
            h = h.substr(k + 1, d - k - 1), h ? h = parseInt(h) : h = 0;
        } else h = 0;
        var j = $("#li-comment-" + n).find("#cdc_oppose_" + l + ":first").html();
        if (j) {
            var f = j.lastIndexOf("("), m = j.lastIndexOf(")");
            j = j.substr(f + 1, m - f - 1), j ? j = parseInt(j) : j = 0;
        } else j = 0;
        g && (g == "SUPPORT" && ($(this).find("#cdc_support_" + l).html("顶(" + h + ")"), $(this).find("#cdc_oppose_" + l).html("踩(" + j + ")"), $(this).find("#cdc_support_" + l).parent().parent().find("span").addClass("whiteColor")), g == "OPPOSE" && ($(this).find("#cdc_support_" + l).html("顶(" + h + ")"), $(this).find("#cdc_oppose_" + l).html("踩(" + j + ")"), $(this).find("#cdc_oppose_" + l).parent().parent().find("span").addClass("whiteColor"))), $(this).children(".commentBlockquote_div").addClass("commentBlockquoteHover"), $(this).addClass("whiteBgHover"), c.stopPropagation();
    }), jQuery(".commentBlockquote").mouseout(function(c) {
        $(this).children(".commentBlockquote_div").removeClass("commentBlockquoteHover"), $(this).removeClass("whiteBgHover"), c.stopPropagation();
    });
}